import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '账号',
    align:"center",
    dataIndex: 'account'
   },
   {
    title: '密码',
    align:"center",
    dataIndex: 'password'
   },
   {
    title: '所属学科',
    align:"center",
    dataIndex: 'subjectId_dictText'
   },
   {
    title: '最近登录时间',
    align:"center",
    dataIndex: 'latestLoginTime'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
     {
      label: "账号",
      field: "account",
      component: 'Input', //TODO 范围查询
      //colProps: {span: 6},
	},
	{
      label: "所属学科",
      field: 'subjectId',
      component: 'JSelectMultiple',
      componentProps:{
          dictCode:"t_subject,subject_name,id"
      },
      //colProps: {span: 6},
 	},
     {
      label: "最近登录时间",
      field: "latestLoginTime",
      component: 'RangePicker',
      componentProps: {
          valueType: 'Date',
          showTime:true
      },
      //colProps: {span: 6},
	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '账号',
    field: 'account',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入账号!'},
                 {...rules.duplicateCheckRule('t_app_user', 'account',model,schema)[0]},
          ];
     },
  },
  {
    label: '密码',
    field: 'password',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入密码!'},
          ];
     },
  },
  {
    label: '所属学科',
    field: 'subjectId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"t_subject,subject_name,id"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入所属学科!'},
          ];
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  account: {title: '账号',order: 0,view: 'text', type: 'string',},
  password: {title: '密码',order: 1,view: 'text', type: 'string',},
  subjectId: {title: '所属学科',order: 2,view: 'list', type: 'string',dictTable: "t_subject", dictCode: 'id', dictText: 'subject_name',},
  latestLoginTime: {title: '最近登录时间',order: 3,view: 'datetime', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}